class ObserverAnalyzer
  attr_reader :results

  def initialize
    @results = Hash.new
  end

  def update arg
    arg = arg.winning_cards.pop.to_s
    if @results.has_key?arg
      @results[arg] += 1
    elsif
      @results[arg] = 1
    end
  end

  def analyse
    sum = 0
    winners = Hash.new
    @results.values.each do
      |value| if value.nil?
                next
              end
      sum += value.to_i
    end

   @results.each_pair do |k,v|
     if @results[k].to_i > 0
       winners[k] = v.to_f / sum * 100
     end
   end
    puts "-------------------"
    puts "Observer analyser recorded: #{sum} winner cards"
    puts "Winning odds in %:"
    puts winners.sort_by {|k,v| v}
    puts "-------------------"
  end
  end